/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assisisw.smartcal.webuisubsystem.managedbean;

import assisisw.smartcal.entitysubsystem.User;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;

/**
 *
 * @author Francesco
 */
@ApplicationScoped ()
@Named ()
@Singleton ()
public class NotificationClientsEndpoint implements INotificationClientsEndpoint 
{

    // Instance Fields
    
    private Map < User , DashboardBean > loggeds ;
    
    // Instance Methods
    
    /***/
    public NotificationClientsEndpoint () {}
    
    /***/
    @PostConstruct
    public void init () 
    {
        loggeds = new LinkedHashMap <> () ;
    }
    
    /**
     * @param user
     * @param dashboardBean 
     */
    @Override
    public void register ( User user , DashboardBean dashboardBean ) 
    {
        if ( ! loggeds.containsKey ( user ) )
        {
            loggeds.put ( user, dashboardBean ) ;
            // retrieve notifications
        }
    }
    
    @Override
    public void unregister ( User user ) 
    {
        if ( loggeds.containsKey ( user ) )
        {
            loggeds.remove ( user ) ;
        }
    }

    /**
     * AS THE SUPER'S ONE.
     */
    @Override
    public DashboardBean getDashboardBean(User user) 
    {
        return loggeds.get ( user ) ;
    }
    
}
